<template>
  <div class="order">
    <Tabs :text="text">
      <Search @data="upState" @easySearch="easySearch" v-if="searchState" />
    </Tabs>
    <SearchItem v-if="state" :position="position"></SearchItem>
    <router-view></router-view>
  </div>
</template>

<script>
import Tabs from "../components/Tabs.vue";
import Search from "../components/Search.vue";
import SearchItem from "../components/OrderHighSearch.vue";
import { mapMutations } from 'vuex';
export default {
  components: {
    Tabs,
    Search,
    SearchItem,
  },
  data() {
    return {
      text: [
        {
          id: "0",
          textName: "订单列表",
          url: "/order/orderlist",
        },
        {
          id: "1",
          textName: "今日新增",
          url: "/order/orderadd-day",
        },
        {
          id: "2",
          textName: "本周新增",
          url: "/order/orderadd-week",
        },
        {
          id: "3",
          textName: "本月新增",
          url: "/order/orderadd-month",
        },
        {
          id: "4",
          textName: "数据导出",
          url: "/order/orderlist",
        },
        {
          id: "5",
          textName: "新增订单",
          url: "/order/addorder",
        },
      ],
      state: false,
      // 搜索状态值
      searchState:true,
      position: [],
    };
  },
  methods: {
     ...mapMutations(['setSearchVal']),
    upState(data) {
      this.state = !data; //状态处理
    },
    easySearch(val) {
      this.setSearchVal(val);
    },
  },
  watch:{
    $route(to){
      console.log('Order路由监听',to);
      if(to.path=='/order/addorderpage'){
        this.searchState=false
      } else{
        this.searchState=true
      }
    }
  }
};
</script>

<style>
</style>